package com.triones.api.controller.api;

import cn.dev33.satoken.annotation.SaIgnore;
import com.google.gson.JsonObject;
import com.ruoyi.common.core.controller.BaseController;
import com.triones.api.service.third.ApiThirdCallbackService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * api - 用户会员相关接口
 *
 * @Author: triones
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/third/callback")
public class ApiThirdCallbackController extends BaseController {

    private final ApiThirdCallbackService apiThirdCallbackService;

    /**
     * php回调接口
     * @param request
     * @throws Exception
     */
    @SaIgnore
    @RequestMapping("/php")
    public ResponseEntity<Map<String, Boolean>> phpCardTrade(HttpServletRequest request) throws Exception {
        return apiThirdCallbackService.phpCardTrade(request);
    }

    /**
     * lpt事件回调接口
     * @param request
     * @throws Exception
     */
    @SaIgnore
    @PostMapping("/lpt")
    public ResponseEntity<Map<String, Object>> lptEventNotification(HttpServletRequest request) throws Exception {
        return apiThirdCallbackService.lptEventNotification(request);
    }

    /**
     * lpt提币交易确认
     * @param request
     * @throws Exception
     */
    @SaIgnore
    @PostMapping("/lpt/tradeConfirm")
    public ResponseEntity<Map<String, Object>> lptTradeConfirmNotification(HttpServletRequest request) throws Exception {
        return apiThirdCallbackService.lptTradeConfirmNotification(request);
    }
}
